<?php

namespace App\Store\Validate\Wxapp;

use App\Common\Validate\BaseValidate;

/**
 * 权限组验证器
 */
class WxSetting extends BaseValidate
{

    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];
    

    public function __construct($doaction = 'wxaccount')
    {

        if ($doaction == 'wxaccount') {
            $this->rule = [
                'appid'=>'required',
                'appsecret'=>'required',
                'token'=>'required',
                'encodingaeskey'=>'required|size:43',
                'welcomemsg'=>'required',
            ];
            $this->message = [
                'appid.required' => 'appid不能为空',
                'appsecret.required' => 'appsecret不能为空',
                'token.required' => '令牌(Token)不能为空',
                'encodingaeskey.required' => '消息加解密密钥不能为空',
                'encodingaeskey.size' => '消息加解密密钥必须为43位字符串',
                'welcomemsg.required' => '关注欢迎语不能为空',
            ];
        } elseif ($doaction == 'wxapp') {
            $this->rule = [
                'appid'=>'required',
                'appsecret'=>'required',
                'wxpay_mchid'=>'required',
                'wxpay_key'=>'required',
                'wxpay_cert_path'=>'required',
                'wxpay_key_path'=>'required',
                'wxpay_platform_certs_path'=>'required',
                'contact_phone'=>'required',
                'contact_wxaccount'=>'required'
            ];
            $this->message = [
                'appid.required' => 'appid不能为空',
                'appsecret.required' => 'appsecret不能为空',
                'token.required' => '微信支付商户号不能为空',
                'wxpay_key.required' => '微信支付密钥（V3）不能为空',
                'wxpay_cert_path.required' => '微信支付cert证书不能为空',
                'wxpay_key_path.required' => '微信支付key证书不能为空',
                'wxpay_platform_certs_path'=>'平台证书不能为空',
                'contact_phone.required' => '联系电话不能为空',
                'contact_wxaccount.required' => '微信联系不能为空',
            ];
        }
    }
}
